package net.sk.china.city.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class ArRegionTreeSelect implements Serializable {
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    private Long id;

    /** 节点名称 */
    private String label;

    /** 编码 */
    private String regionCode;

    /** 经度 */
    private BigDecimal longitude;

    /** 纬度 */
    private BigDecimal latitude;

    /** 是否为网格 0:非 1:是*/
    private Integer isCell;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<ArRegionTreeSelect> children;

    public ArRegionTreeSelect()
    {

    }

    public ArRegionTreeSelect(ArRegion arRegion)
    {
        this.id = arRegion.getPkId();
        this.label = arRegion.getName();
        this.regionCode = arRegion.getRegionCode();
        this.longitude = arRegion.getLongitude();
        this.latitude = arRegion.getLatitude();
        this.isCell = arRegion.getIsCell();
        this.children = arRegion.getChildren().stream().map(ArRegionTreeSelect::new).collect(Collectors.toList());
    }
}
